package border;

import square.Direction;
import square.Square;
import square.TransparentSquare;
import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Immutable;
import be.kuleuven.cs.som.annotate.Raw;


/**
 * A class for constructing a wall, attached to maximum 2 squares.
 * 
 * @version	3.0
 * @author Inge Gielis <inge.gielis@student.kuleuven.be>
 * @author Annelies Ketelslegers <annelies.ketelslegers@student.kuleuven.be> 
 */
public class Wall extends Border {
	
	
	/**
	 * Initialize this new wall attached to the given squares in 
	 * the given direction and with the given slippery state.
	 * 
	 * @param	isSlippery
	 * 			The state for the slipperiness of this new wall.
	 * @post	The slippery state of this new wall is equal to the
	 * 			given flag.
	 * 			| new.isSlippery() = isSlippery
	 * @effect 	This new wall is initialized as a border with the given 
	 * 			squares and the given direction.
	 * 			|super(square1, square2, direction)
	 * @throws	IllegalArgumentException
	 * 			Transparent squares cannot have walls.
	 * 			| if(square1 instanceof TransparentSquare || square2 instanceof TransparentSquare)
	 */
	@Raw
	public Wall(Square square1, Square square2, Direction direction, 
			boolean isSlippery){
		super(square1, square2, direction);
		if(square1 instanceof TransparentSquare || square2 instanceof TransparentSquare)
			throw new IllegalArgumentException("Transparent squares cannot have walls.");
		IS_SLIPPERY = isSlippery;
	}



	/**
	 * Initialize this new wall attached to the given square 
	 * in the given direction and define the wall as slippery or not.
	 * 
	 * @param	isSlippery
	 * 			The state for the slipperiness of this new wall.
	 * @post	The slippery state of this new wall is equal to the
	 * 			given flag.
	 * 			| new.isSlippery() = isSlippery
	 * @effect 	This new wall is initialized as a border with 
	 * 			the given square and the given direction.
	 * 			| super(square, direction)
	 * @throws	IllegalArgumentException
	 * 			Transparent squares cannot have walls.
	 * 			| if(square instanceof TransparentSquare) 
	 */
	@Raw
	public Wall(Square square, Direction direction, boolean isSlippery) throws IllegalArgumentException{
		super(square, direction);
		if(square instanceof TransparentSquare)
			throw new IllegalArgumentException("Transparent squares cannot have walls.");
		IS_SLIPPERY = isSlippery;
	}
	
	
	
	/**
	 * Check if the wall is slippery.
	 */
	@Basic @Immutable
	public boolean isSlippery(){
		return IS_SLIPPERY;
	}
	
	/**
	 * Variable referencing the slipperiness of the wall.
	 */
	private final boolean IS_SLIPPERY;
	
	/**
	 * Return a textual representation of this wall.
	 * 
	 * @return	A string consisting of the word "Wall:", followed
	 * 			by "Slippery" or "Not Slippery", depending on the state of this wall.
	 * 			| result.equals(
	 * 			|	"Wall: " + (this.isSlippery() ? "Slippery" : "Not slippery") +" \n")
	 */
	@Override
	public String toString() {
		String result = "Wall: ";
		result += (this.isSlippery() ? "Slippery" : "Not slippery") +" \n";
		return result;
	}

}
